
package com.joolun.cloud.mall.admin.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.joolun.cloud.mall.common.entity.UserInfo;
import com.joolun.cloud.mall.admin.mapper.UserInfoMapper;
import com.joolun.cloud.mall.admin.service.UserInfoService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 商城用户
 *
 * @author www.joolun.com
 * @date 2019-12-04 11:09:55
 */
@Service
@AllArgsConstructor
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements UserInfoService {

	@Override
	public IPage<UserInfo> page1(IPage<UserInfo> page, UserInfo userInfo) {
		return baseMapper.selectPage1(page,userInfo);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void updatePoints(String userId, Integer posts) {
		baseMapper.update(new UserInfo(), Wrappers.<UserInfo>lambdaUpdate()
				.eq(UserInfo::getId, userId)
				.setSql(" points_current = points_current + " + posts));
	}
}
